﻿@model Century.Model.CMS.SitePage
@{
    Layout = null;    

    var optionCSS = new AjaxOptions()
    {
        Url = Url.Action("AdvancedCSS", "PageManagement"),
        UpdateTargetId = "Result",
        OnSuccess = "OnSuccessAdvanced",
        OnFailure = "OnFailureAdvanced"
    };

    var optionMeta = new AjaxOptions()
    {
        Url = Url.Action("AdvancedMeta", "PageManagement"),
        UpdateTargetId = "Result",
        OnSuccess = "OnSuccessAdvanced",
        OnFailure = "OnFailureAdvanced"
    };

    var optionJS = new AjaxOptions()
    {
        Url = Url.Action("AdvancedJS", "PageManagement"),
        UpdateTargetId = "Result",
        OnSuccess = "OnSuccessAdvanced",
        OnFailure = "OnFailureAdvanced"
    };
}


@Html.Partial("_MessageBox")
<script type="text/javascript">

    function OnSuccessAdvanced(data) {
        OpenPopup('Message', 'Successfully saved', false);
        $("#CssPath").val('');
        $("#JSPath").val('');
        $("#MetaName").val('');
        $("#MetaValue").val('');
        ReloadAll();
    }

    function ReloadAll() {
       @* ReloadDetail('@(Url.Action("AdvancedDetail", "PageManagement", new { type = Century.Common.Enumerations.SitePageParameterType.Css}))', 'css_list');
        ReloadDetail('@(Url.Action("AdvancedDetail", "PageManagement", new { type = Century.Common.Enumerations.SitePageParameterType.Js}))', 'js_list');
        ReloadDetail('@(Url.Action("AdvancedDetail", "PageManagement", new { type = Century.Common.Enumerations.SitePageParameterType.CustomMetaTag}))', 'meta_list');*@
    }

    function OnFailureAdvanced(data) {
        OpenPopup('Message', 'An error occured during save operation. <br/>Please try again or contact with administrator.', true);
    }

    function ReloadDetail(url, divID) {
        $.post(url, function (data) {
            $('#' + divID).html(data);
        });
    }

    function DeleteSitePageParameter(id) {
        $.get('@(Url.Action("AdvancedItemDelete", "PageManagement"))' + '/' + id, function (data) {
            ReloadAll();
        });
    }

</script>

@{Html.EnableClientValidation();}
<div style="text-align: left; min-height: 600px; margin-bottom: 20px;">
    <table border="0" cellspacing="0" cellpadding="0" class="advanced-tbl">
        <tr>
            <td colspan="2">
                <h2>
                    Advanced Settings</h2>
                <br />
                <img src="@Url.Content("~/Areas/Admin/Content/themes/admin/img/general/warning.png")" alt="Warning">
                Please don't change if you are not sure !<br />
                <img src="@Url.Content("~/Areas/Admin/Content/themes/admin/img/general/warning.png")" alt="Warning">
                Your changes will be appear on <b>Live</b>. There is no draft or etc. version for these properties
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <img src="@Url.Content("~/Areas/Admin/Content/themes/admin/img/general/css.png")" alt="CSS">
                You can add custom css file(s) for page
            </td>
        </tr>
        @using (Ajax.BeginForm(optionCSS)) 
        {
            <tr>
                <td>
                    Page Based CSS :
                </td>
                <td class="lbl">
                        @Html.ValidationSummary(true)
                        <input type="hidden" id="SitePageId" name="SitePageId" value="@(Model.Id)" />
                        <input type="text" id="CssPath" name="CssPath" class="big" readonly="readonly" />
                        @*@Html.FileExplorerFor("~/Content/themes/default/css", "CssPath")*@
                        <input type="submit" value="+" />
                </td>
            </tr>
            
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <ul id="css_list" class="css_list">
                            @*@Html.Action("AdvancedDetail", "PageManagement", new { type = Century.Common.Enumerations.SitePageParameterType.Css})*@
                        </ul>
                    </td>
                </tr>
            
        }
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <img src="@Url.Content("~/Areas/Admin/Content/themes/admin/img/general/script.png")" alt="CSS">
                You can add custom js file(s) for page
            </td>
        </tr>
        @using (Ajax.BeginForm(optionJS)) 
        {
            <tr>
                <td>
                    Page Based JS :
                </td>
                <td class="lbl">
                        @Html.ValidationSummary(true)
                        <input type="hidden" id="SitePageId" name="SitePageId" value="@(Model.Id)" />
                        <input type="text" id="JSPath" name="JSPath" class="big" readonly="readonly" />
                        @*@Html.FileExplorerFor("~/Content/themes/default/js", "JSPath")*@
                        <input type="submit" value="+" />
                </td>
            </tr>
            
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <ul id="js_list" class="js_list">
                            @*@Html.Action("AdvancedDetail", "PageManagement", new { type = Century.Common.Enumerations.SitePageParameterType.Js})*@
                        </ul>
                    </td>
                </tr>
            
        }
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <img src="@Url.Content("~/Areas/Admin/Content/themes/admin/img/general/html.png")" alt="Html">
                You can add custom meta definitions for page
            </td>
        </tr>
        @using (Ajax.BeginForm(optionMeta))
        {
            <tr>
                <td>
                    Custom Meta :
                </td>
                <td class="lbl">
                    @Html.ValidationSummary(true)
                    <input type="hidden" id="SitePageId" name="SitePageId" value="@(Model.Id)" />
                    <input type="text" id="MetaName" name="MetaName" class="half_big" />
                    <input type="text" id="MetaValue"  name="MetaValue" class="half_big" />
                    <input type="submit" value="+" />
                </td>
            </tr>
            
            
                 <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <ul id="meta_list" class="meta_list">
                            @*@Html.Action("AdvancedDetail", "PageManagement", new { type = Century.Common.Enumerations.SitePageParameterType.CustomMetaTag})*@
                        </ul>
                    </td>
                </tr>
           
        }
    </table>
</div>
